#pragma once
#include "SipRobot.h"

class CSIPDriverActor : public CBaseActor
{
public:
    CSIPDriverActor (CSipRobot* pSip) ;
	
    ~CSIPDriverActor ();
   
	int HandleConnect();

	int HandleDriverRegister();

	int HandleWaitAnswerRegister();
    
    int HandleRegisterAuth();

	int HandleWaitAnswerRegAuth();
    
    int HandleIdle();
	int HandleWaitIdle();
   
private:
	CSipRobot*  mpSipDriver;
};

class CDriverConnectFsm : public IFsmState
{
public:
    CDriverConnectFsm () {}
    virtual ~CDriverConnectFsm () {}
    virtual int BeginState(IActor* obj)
    {      
        return 0;
    }
    virtual int UpDataState(IActor* obj)
    {
        CSIPDriverActor * chirdObj = (CSIPDriverActor*) obj;
        int ret = chirdObj->HandleConnect();
        if (ret > 0)
        {
            return 1;
        }

		return 0;
    }
    virtual int EndState(IActor* obj)
    {        
        return 0;
    }
};

class CRegisterDriverFsm : public IFsmState
{
public:
    CRegisterDriverFsm () {}
    virtual ~CRegisterDriverFsm () {}
    virtual int BeginState(IActor* obj)
    {
        return 0;
    }
    virtual int UpDataState(IActor* obj)
    {
        CSIPDriverActor * chirdObj = (CSIPDriverActor*) obj;
        int ret = chirdObj->HandleDriverRegister();
        if (ret > 0)
        {
            return ret;
        }

		return 0;
    }
    virtual int EndState(IActor* obj)
    {
        return 0;
    }
};


class CWaitAnswerRegisterFsm : public IFsmState
{
public:
    CWaitAnswerRegisterFsm () {}
    virtual ~CWaitAnswerRegisterFsm () {}
    virtual int BeginState(IActor* obj)
    {
        return 0;
    }
    virtual int UpDataState(IActor* obj)
    {
        CSIPDriverActor * chirdObj = (CSIPDriverActor*) obj;
        int ret = chirdObj->HandleWaitAnswerRegister();
        if (ret > 0)
        {
            return ret;
        }

		return 0;
    }
    virtual int EndState(IActor* obj)
    {
        return 0;
    }
};

class CRegisterDriverAuthFsm : public IFsmState
{
public:
    CRegisterDriverAuthFsm () {}
    virtual ~CRegisterDriverAuthFsm () {}
    virtual int BeginState(IActor* obj)
    {
        return 0;
    }
    virtual int UpDataState(IActor* obj)
    {
        CSIPDriverActor * chirdObj = (CSIPDriverActor*) obj;
        int ret = chirdObj->HandleRegisterAuth();
        if (ret > 0)
        {
            return ret;
        }
        return 0;
    }
    virtual int EndState(IActor* obj)
    {
        return 0;
    }
};


class CWaitAnswerRegAuthFsm : public IFsmState
{
public:
    CWaitAnswerRegAuthFsm () {}
    virtual ~CWaitAnswerRegAuthFsm () {}
    virtual int BeginState(IActor* obj)
    {
        return 0;
    }
    virtual int UpDataState(IActor* obj)
    {
        CSIPDriverActor * chirdObj = (CSIPDriverActor*) obj;
        int ret = chirdObj->HandleWaitAnswerRegAuth();
        if (ret > 0)
        {
            return ret;
        }
        return 0;
    }
    virtual int EndState(IActor* obj)
    {
       return 0;
    }
};

class CDriverKeepFsm : public IFsmState
{
public:
    CDriverKeepFsm () {}
    virtual ~CDriverKeepFsm () {}
    virtual int BeginState(IActor* obj)
    {
        return 0;
    }
    virtual int UpDataState(IActor* obj)
    {
        CSIPDriverActor * chirdObj = (CSIPDriverActor*) obj;
        int ret = chirdObj->HandleIdle();
        if (ret > 0)
        {
            return ret;
        }
        return 0;
    }
    virtual int EndState(IActor* obj)
    {
        return 0;
    }
};


class CWaitAnswerKeepFsm : public IFsmState
{
public:
    CWaitAnswerKeepFsm () {}
    virtual ~CWaitAnswerKeepFsm () {}
    virtual int BeginState(IActor* obj)
    {
        return 0;
    }
    virtual int UpDataState(IActor* obj)
    {
        CSIPDriverActor * chirdObj = (CSIPDriverActor*) obj;
        int ret = chirdObj->HandleWaitIdle();
        if (ret > 0)
        {
            return ret;
        }
        return 0;
    }
    virtual int EndState(IActor* obj)
    {
        return 0;
    }
};
